Change File Type 96 r1

by Jack Mathews

Well, I think that the title makes this app pretty self explanatory.  Basically, its a Windows 95 Shell Extension that takes advantage of the Windows 95 Shell, including obtaining shell icons and reading the registry for File Types.  

Installation and Uninstallation

	First, of course, you must run the Setup program.  This creates the file "FILETYPE.DLL" in your Windows System folder.  It then registers the shell extension and its uninstallation in the registry..  You can delete setup then if you like.  The uninstall can be found under Add/Remove Programs in the Control Panel.  You don't need the setup file to uninstall and every remnant (files and all) of the program will be deleted the next time you restart Windows.

Usage

After you install Change File Type 96, it adds "Change File Type" to the right-click menu of any type of file (except shortcuts) like so:

When you click "Change File Type", a dialog box similar to this will pop up:

	This box should be pretty easy to figure out.  However, I will explain it anyways.  The icon and name at the top are the icon and name for the selected file.  The "From:" field contains the file extension and the file type.  The "To:" field contains the same.  You can either type in an extension (and it will tell you the file type as you type it in) or you can select the File Type on the right and have the extension pop up on the left.  If there are more than one extension for a single type (i.e. WinZip registers ARC, ARJ, GZ, Z, ZIP, et cetera all under the type "WinZip File"), you can use the up-down arrows to go between the different extensions.
	If a file type is too long in either the From or To fields, float over the type name and a ToolTip will extend the text past the end of the window.
	OK will obviously rename the file and let you go on your merry way, Cancel will leave the file alone, and Apply lets you rename the file then update the icon, display name and the "From" fields.
	Change File Type also keeps the icon in the same place when you rename it.  That means when you rename a file in a folder, it won't move to the end of the list or if you rename a file on your desktop it keeps its position.  I haven't seen any others that do this.
	Regarding this:.  You may see this little gem instead of file icons if you hit the drop-down list very soon after starting the program.  That is because it takes time to process all the icons for each file type, so I made that a second thread (running in the background).  When you come across an icon it hasn't yet processed, you get the hourglass.  As you move over the list items, the hourglasses will disappear and be replaced by the real icons. 
	For all you programmers out there, this is what I did for the major parts of the program:
1) The flip effect - EMail me for the Zoom functions
2) Obtaining file-type information: First, I used the RegEnumKeys function to get all the extensions and types and dumped them into two linked-lists.  (By the way, since global variables in DLLs are global for every instance of it, I dumped all this seemingly "global" data into a class and I use SetProp in the WM_INITDIALOG to tell it to refer to this variable.)  Then I started a thread (using _beginthread) to hop through the linked lists and create and close a file in the Windows\Temp folder (GetTempPath) called "$$JACK$$.<ext>".  I then use SHGetFileInfo to get the selected and unselected states of the icons from the shell, then I delete the file.
3) The icon in the upper left is an owner-draw button and I use SHGetFileInfo for the icon and the display name next to it.
4) In the from field, the file type is from the SHGetFileInfo, in the To field, its from the registry (or "<ext> File" if its an unregistered extension
5) How I made an owner draw combo box with an edit field: (BTW, I had to do this so that if the user typed in an unregistered extension, it would display "<ext> File".  Easy.  In the WM_INITDIALOG, I used MoveWindow to move the Edit field over 16 pixels (and down 2).  Then I subclassed the window (using SetWindowLong with GWL_WNDPROC) and whenever the combo box receives a WM_PAINT message, it runs the old paint procedure and the sends a custom message back to the parent for it to repaint the icon.  It also repaints when the user enters an extension.
6) The tooltips.  This was actually a VERY arduous process.  I knew I had to subclass it.  You see, under normal circumstances, the tooltip won't display if the mouse is over the tip.  I just thought that filtering the WM_MOUSEMOVE would solve.  Then, it would pop up and immediately disappear.  After nearly tossing the monitor out the window, I went into Spy++.  After about 10 minutes of filtering the messages, I found the culprit.  It was a timer: number 3 to be precise.  So what I had to do was abort the Window procedure if I got a WM_TIMER with a wParam of 3 if the mouse is over the tip, and then hide the tip on a mouse click.  Whew.
7) Lastly is how I made the window flip from the center of the icon you clicked instead of where the mouse was:  Well, I used good old Spy++ for this as well as remembering one thing: since this is DLL loaded by Explorer, not only can you crash Explorer, but you can use any of its windows.  So all I did was get the parent Window, used FindWindowEx to find the first child window with the "SHELLDLL_DefView" class, and then the first child of THAT with the "SysListView32" Class.  From there I used standard ListView macros to  find the currently selected file and get the icon's bounding rectangle.  If any of this fails (like it does with the Microsoft Office Shortcut Bar), the flip effect relies on the mouse position.

If you have any more questions or suggestions on anything (including programming), E-Mail me.  My address is at the bottom of the page.

This is Freeware?  What's the catch?

	There is no catch.  I made this as a learning tool for myself and as a utility.  Just thought I'd give a little back to the Internet community.  I would appreciate feedback and if you want to send me money :-) 

So what's your E-Mail address?

jm66626@pegasus.cc.ucf.edu

Hey, are you the same asshole who
wrote the Mac96=Win95 article?

Yes I am!  And you can find it at http://www.win95mag.com/96.2

Hope you enjoy the program!